package com.jojo.bubble.controller.api;

import com.jojo.bubble.common.domain.AjaxResult;
import com.jojo.bubble.entity.Shop;
import com.jojo.bubble.service.AgentService;
import com.jojo.bubble.service.ShopService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author JoJo
 * @Date 2023/8/28 13:50
 * @Description
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/shop")
public class ShopApiController {
    @Resource
    ShopService shopService;

    @Resource
    AgentService agentService;

    @GetMapping("/info")
    public AjaxResult getInfo(int id) {
        Shop shop = shopService.getInfo(id);
        return AjaxResult.success(shop);
    }

    @GetMapping("/list")
    public AjaxResult getList(Shop record) {
        List<Shop> shopList = shopService.getList(record);
        return AjaxResult.success(shopList);
    }

    @PostMapping("/insert")
    public AjaxResult insertShop(Shop shop) {
        shopService.insert(shop);
        return AjaxResult.success();
    }

    @PostMapping("/update")
    public AjaxResult update(Shop shop) {
        shopService.update(shop);
        return AjaxResult.success();
    }
}
